<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var intersect = function (nums1, nums2) {
            // console.log(nums1,nums2)
            let arr = []
            for (let i = 0; i < nums1.length; i++) {
                for (let j = 0; j < nums2.length; j++) {
                    if (nums1[i] === nums2[j]) {
                        console.log(i)
                        // arr.push(nums1[i])
                        arr[i] = nums1[i]
                    }
                }
            }
            // arr = [...new Set(arr)]
            // arr = new Set(arr)
            return arr
        };
        const res = intersect([1,2,2,1], [2,2])
        console.log(res) // [4,9]
    </script>
</head>

<body>

</body>

</html>